package com.chz.SupermarketMS.dao;


import com.chz.SupermarketMS.dto.ChartData;
import com.chz.SupermarketMS.dto.KindCommodities;
import com.chz.SupermarketMS.entities.Kind;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface KindRepository extends CrudRepository<Kind, Long> {

    @Override
    List<Kind> findAll();


    @Query(nativeQuery = true,value = "SELECT type as label, COUNT(*) as value FROM chz.kind group by type")
    List<ChartData> getKindType();

    Kind findByKindId(long theId);


}
